import {combineReducers} from 'redux'
import regist from './regist'
import login from './login'
import home from './home'
import course from './course'
import myself from './myself'
import theme from './theme'
// import mall from './mall'
import {rootCom, RootNavigator} from '../../navigator/AppNavigator.js';

//1.指定默认state
const navState = RootNavigator.router.getStateForAction(RootNavigator.router.getActionForPathAndParams(rootCom));

//2. 创建自己的的navigation reducer
const navReducer = (state = navState, action) => {
  const nextState = RootNavigator.router.getStateForAction(action, state);
  // 如果`nextState`为null或未定义，只需返回原始`state`
  return nextState || state;
}


/**
 * 3.合并reducer
 * @type {Reducer<any> | Reducer<any, AnyAction>}
 */

 const index = combineReducers({
  nav: navReducer,
  regist: regist,
  login: login,
  home: home,
  course: course,
  myself: myself,
  theme: theme,
  // mall: mall
 })

 export default index

